using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Editors_Calendar : BasePage {
    private IWeatherForecastProvider weatherForecastProvider = null;
    private TemperatureUnit currentTemperatureUnit = TemperatureUnit.Fahrenheit;

    protected IWeatherForecastProvider WeatherForecastProvider {
        get {
            if(weatherForecastProvider == null) {
                weatherForecastProvider = Application["WeatherForecastProvider"] as IWeatherForecastProvider;
                if(weatherForecastProvider == null)
                    weatherForecastProvider = RandomWeatherForecastProvider.Instance;
            }
            return weatherForecastProvider;
        }
    }

    protected void Page_Load(object sender, EventArgs e) {
        this.currentTemperatureUnit = ((string)cbTemperatureUnit.Value == "Fahrenheit") ? TemperatureUnit.Fahrenheit : TemperatureUnit.Celsius;
    }
    protected void OnCalendarDayRender(object sender, DevExpress.Web.ASPxEditors.DayRenderEventArgs e) {
        e.Day.IsWeekend = false;
        WeatherInfo info = WeatherForecastProvider.GetWeatherInfo(e.Day.DateTime);
        e.Controls.Add(new WeatherInfoControl(info, this.currentTemperatureUnit));
    }
}
